using DimensionsHelper.LanguageService.Symbols;
using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisModuleSignature : AnalysisStatementWithDomain
{
    internal AnalysisModuleSignature(
        ModuleSignature syntaxNode,
        ModuleSymbol moduleSymbol,
        AnalysisNode? parent) :
        base(AnalysisBoundKinds.ModuleSignature, syntaxNode, moduleSymbol, parent)
    {
        Syntax = syntaxNode;
        // 移除NameIdentifier
        Children.Clear();
        QualifiedName = AnalysisNodeFactory.QualifiedName(syntaxNode.QualifiedName, this,
            AnalysisQualifiedNameFlags.ModuleName);
        Children.Add(QualifiedName);
    }

    public AnalysisQualifiedName QualifiedName { get; }

    public override ModuleSignature Syntax { get; }

    public override AnalysisBlock? Body => null;
}


public static partial class AnalysisNodeFactory
{
    /// <summary>
    /// 创建一个模块签名
    /// </summary>
    /// <param name="syntaxNode">原始语法节点</param>
    /// <param name="moduleSymbol">声明符号</param>
    /// <param name="parent">父节点，可以忽略</param>
    public static AnalysisModuleSignature ModuleSignature(
        ModuleSignature syntaxNode,
        ModuleSymbol moduleSymbol,
        AnalysisNode? parent)
    {
        return new AnalysisModuleSignature(syntaxNode, moduleSymbol, parent);
    }
}